<template>
  <div>
    <van-search placeholder="请输入搜索内容"></van-search>
    <van-swipe>
      <van-swipe-item v-for="(v, i) in banners" :key="i">
        <img :src="v" alt="" width="100%" height="200" />
      </van-swipe-item>
    </van-swipe>
    <div class="list">
      <ListItem v-for="v in list" :key="v.id" :v="v" @click="handleClick(v.id)"></ListItem>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'
import ListItem from '@/components/list-item/index.vue'
const router = useRouter()
const banners = ref([])
const list = ref([])
const _getBanners = async () => {
  const resp = await axios.get('/api/banners')
  banners.value = resp.data.data
}
const _getList = async () => {
  const resp = await axios.get('/api/list')
  list.value = resp.data.data
}
const handleClick = (id) => {
  // 进入详情
  router.push(`/detail/${id}`)
}
_getBanners()
_getList()
</script>

<style scoped lang="scss"></style>
